/**
 * 
 */
package com.swim.settlementapply.web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.jeesite.common.config.Global;
import com.jeesite.common.entity.Page;
import com.jeesite.common.web.BaseController;
import com.swim.settlementapply.entity.SettlementApplyItem;
import com.swim.settlementapply.service.SettlementApplyItemService;

/**
 * 结算申请明细表Controller
 * @author 刘军武
 * @version 2021-04-08
 */
@Controller
@RequestMapping(value = "${adminPath}/settlementapply/settlementApplyItem")
public class SettlementApplyItemController extends BaseController {

	@Autowired
	private SettlementApplyItemService settlementApplyItemService;
	
	/**
	 * 获取数据
	 */
	@ModelAttribute
	public SettlementApplyItem get(String id, boolean isNewRecord) {
		return settlementApplyItemService.get(id, isNewRecord);
	}
	
	/**
	 * 查询列表
	 */
	@RequiresPermissions("settlementapply:settlementApplyItem:view")
	@RequestMapping(value = {"list", ""})
	public String list(SettlementApplyItem settlementApplyItem, Model model) {
		model.addAttribute("settlementApplyItem", settlementApplyItem);
		return "swim/settlementapply/settlementApplyItemList";
	}
	
	/**
	 * 查询列表数据
	 */
	@RequiresPermissions("settlementapply:settlementApplyItem:view")
	@RequestMapping(value = "listData")
	@ResponseBody
	public Page<SettlementApplyItem> listData(SettlementApplyItem settlementApplyItem, HttpServletRequest request, HttpServletResponse response) {
		Page<SettlementApplyItem> page = settlementApplyItemService.findPage(new Page<SettlementApplyItem>(request, response), settlementApplyItem); 
		return page;
	}

	/**
	 * 查看编辑表单
	 */
	@RequiresPermissions("settlementapply:settlementApplyItem:view")
	@RequestMapping(value = "form")
	public String form(SettlementApplyItem settlementApplyItem, Model model) {
		model.addAttribute("settlementApplyItem", settlementApplyItem);
		return "swim/settlementapply/settlementApplyItemForm";
	}

	/**
	 * 保存结算申请明细表
	 */
	@RequiresPermissions("settlementapply:settlementApplyItem:edit")
	@PostMapping(value = "save")
	@ResponseBody
	public String save(@Validated SettlementApplyItem settlementApplyItem) {
		settlementApplyItemService.save(settlementApplyItem);
		return renderResult(Global.TRUE, text("保存结算申请明细表成功！"));
	}
	
	/**
	 * 删除结算申请明细表
	 */
	@RequiresPermissions("settlementapply:settlementApplyItem:edit")
	@RequestMapping(value = "delete")
	@ResponseBody
	public String delete(SettlementApplyItem settlementApplyItem) {
		settlementApplyItemService.delete(settlementApplyItem);
		return renderResult(Global.TRUE, text("删除结算申请明细表成功！"));
	}
	
}